package com.kapukapu.user.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kapukapu.user.entity.SysRole;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author sivan
 * @since 2020-03-16
 */
public interface SysRoleMapper extends BaseMapper<SysRole> {

	/**
	 * 根据用户id获取用户权限集合
	 * @param userId 用户id
	 * @return
	 */
	@Select("SELECT * FROM sys_user, sys_role LEFT JOIN sys_user_role sur ON sur.role_id = sys_role.id WHERE "
			+ "user_id = #{userId}")
	List<SysRole> getRolesByUserId(@Param("userId") long userId);

}
